import { regular } from './regular'

export default {
  required: { required: true, message: '此为必填项！', trigger: 'blur' },
  selectRequired: {
    required: true,
    message: '此为必填项！',
    trigger: 'change'
  },
  maxLen: len => ({ max: len, message: `不可超过${len}字符`, trigger: 'blur' }),
  name: {
    min: 2,
    max: 16,
    message: '请输入2-16个字符的名称',
    trigger: 'blur'
  },
  description: {
    max: 64,
    message: '请输入64个字符以内的描述',
    trigger: 'blur'
  },
  number: regular.number,
  positiveInteger: regular.positiveInteger,
  positiveMaxInteger: regular.positiveIntegerLen1to5,
  positiveNumber: regular.positiveNumber,
  positiveCanZeroInteger: regular.nonNegativeInteger,
  phone: regular.phone,
  code: regular.codeLen1to32,
  username: regular.usernameLen4to16,
  secretPassword: regular.passwordLen8to32WithSymbol, // 密码root
  // positivePercentageHour: regular.positiveIntegerMaxHour,
  positivePercentageHour: {
    pattern: /(^\d{0,5}$)|(^[0-7]\d{5}$)|(^8[0-6]\d{4}$)|(^87[0-5]\d{3}$)|(^876000$)/,
    trigger: 'blur',
    message: '请输入0~876000之间的整数'
  },
  max1Decimal: regular.max1Decimal,
  max2Decimal: regular.max2Decimal,
  integer8Point2: regular.max8IntN2Decimal,
  urlCheck: regular.normalUrl,
  productNameCheck: {
    pattern: /^[a-zA-Z\u4e00-\u9fa5][\u4e00-\u9fa5\w"'\[\]^.:()_-]{0,127}$/,
    message: '大小写字母或中文开头的中英文、数字和,\'-_()[].:^”'
  },
  characteristicCheck: {
    pattern: /^CUSTOM_[A-Z0-9_]*$/,
    message: '以CUSTOM_ 开头、只能包含大写字母、数字或下划线'
  },
  positivePrice: {
    pattern: /^[1-9]{1}\d*(\.\d{1,2})?$|^0{1}(\.\d{1,2})$/,
    message: '仅能输入大于0的数字，小数位数保留两位位',
    trigger: 'blur'
  },
  nameMin2Max10: {
    min: 2,
    max: 10,
    message: '请输入2-10个字符',
    trigger: 'blur'
  }
}
